/*
Arm Tracker and Glove Demo by Noah Zerkin (noazark AT gmail.com) 2009
Released under GNU GPLv3.0 http://www.opensource.org/licenses/gpl-3.0.html
*/

void drawGrid(int gridSide, int gridSpacing, int gridY){
  if(worldBox && !vid){
  stroke(#00C000);
}
else{
  stroke(150,90);
}
  if(!vid){
  strokeWeight(5);
}
else{
strokeWeight(1);
}
      for(int zLine = -gridSide; zLine <= gridSide; zLine += gridSpacing){
    line(gridSide,gridY+.5*gridSide,zLine,-gridSide,gridY+.5*gridSide,zLine);
    }
    for(int xLine = -gridSide; xLine <= gridSide; xLine += gridSpacing){
    line(xLine,gridY+.5*gridSide,gridSide,xLine,gridY+.5*gridSide,-gridSide);
    }

  if(worldBox){

      stroke(150,150);
      strokeWeight(2);
    
    //Front
    for(int zLine = -gridSide; zLine <= gridSide; zLine += gridSpacing){
    line(gridSide,gridY,zLine,gridSide,gridY-gridSide,zLine);
    }
    for(int yLine = -gridY; yLine <= gridSide-gridY; yLine += gridSpacing){
    line(gridSide,-yLine,gridSide,gridSide,-yLine,-gridSide);
    }
    
    //Back
    for(int zLine = -gridSide; zLine <= gridSide; zLine += gridSpacing){
    line(-gridSide,gridY,zLine,-gridSide,gridY-gridSide,zLine);
    }
    for(int yLine = -gridY; yLine <= gridSide-gridY; yLine += gridSpacing){
    line(-gridSide,-yLine,gridSide,-gridSide,-yLine,-gridSide);
    }
    
    //Right
    for(int zLine = -gridSide; zLine <= gridSide; zLine += gridSpacing){
    line(zLine,gridY,gridSide,zLine,gridY-gridSide,gridSide);
    }
    for(int yLine = -gridY; yLine <= gridSide-gridY; yLine += gridSpacing){
    line(gridSide,-yLine,gridSide,-gridSide,-yLine,gridSide);
    }
    
    //Left
    for(int zLine = -gridSide; zLine <= gridSide; zLine += gridSpacing){
    line(zLine,gridY,-gridSide,zLine,gridY-gridSide,-gridSide);
    }
    for(int yLine = -gridY; yLine <= gridSide-gridY; yLine += gridSpacing){
    line(gridSide,-yLine,-gridSide,-gridSide,-yLine,-gridSide);
    }
    
    //Hell
  for(int zLine = -gridSide; zLine <= gridSide; zLine += gridSpacing){
  line(gridSide,gridY,zLine,-gridSide,gridY,zLine);
  }
  for(int xLine = -gridSide; xLine <= gridSide; xLine += gridSpacing){
  line(xLine,gridY,gridSide,xLine,gridY,-gridSide);
  }
    
    //Ceiling
    stroke(#0000FF, 50);
    for(int zLine = -gridSide; zLine <= gridSide; zLine += gridSpacing){
    line(gridSide,gridY-gridSide,zLine,-gridSide,gridY-gridSide,zLine);
    }
    for(int xLine = -gridSide; xLine <= gridSide; xLine += gridSpacing){
    line(xLine,gridY-gridSide,gridSide,xLine,gridY-gridSide,-gridSide);
    }
    
  }
  strokeWeight(2);
    stroke(100);
}
